home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Programming / ixemul / include / packets.h < prev    next >
C/C++ Source or Header  |  1997-10-28  |  3KB  |  89 lines

  1. /*
  2.  *  This file is part of ixemul.library for the Amiga.
  3.  *  Copyright (C) 1991, 1992  Markus M. Wild
  4.  *
  5.  *  This library is free software; you can redistribute it and/or
  6.  *  modify it under the terms of the GNU Library General Public
  7.  *  License as published by the Free Software Foundation; either
  8.  *  version 2 of the License, or (at your option) any later version.
  9.  *
  10.  *  This library is distributed in the hope that it will be useful,
  11.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  *  Library General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU Library General Public
  16.  *  License along with this library; if not, write to the Free
  17.  *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  */
  19.  
  20. #ifndef _PACKETS_H
  21. #define _PACKETS_H
  22.  
  23. #ifdef __pos__
  24.  
  25. #define CTOBPTR(ptr) ((long)ptr)
  26. #define BTOCPTR(ptr) ((void *)ptr)
  27. #define HANDLER_NIL(fp) (!(fp)->f_fh->fh_DosDev)
  28.  
  29. #else
  30.  
  31. #define PutPacket(port,pack) PutMsg((port), (struct Message *)(pack))
  32.  
  33. #define GetPacket(port) ((struct StandardPacket *)GetMsg(port))
  34.  
  35. /***************************************************************************/
  36.  
  37. #define LastResult(f) ((f)->f_sp.sp_Pkt.dp_Res1)
  38. #define LastError(f) ((f)->f_sp.sp_Pkt.dp_Res2)
  39.  
  40. #define SelLastResult(f) ((f)->f_select_sp.sp_Pkt.dp_Res1)
  41. #define SelLastError(f) ((f)->f_select_sp.sp_Pkt.dp_Res2)
  42.  
  43. /***************************************************************************/
  44.  
  45. #define SendPacket0(fp,port,act) \
  46.   ((fp)->f_sp.sp_Pkt.dp_Port = (port), (fp)->f_sp.sp_Pkt.dp_Type = (act), \
  47.   PutPacket((fp)->f_fh->fh_Type, &(fp)->f_sp))
  48.  
  49. #define SendPacket1(fp,port,act,arg1) \
  50.   ((fp)->f_sp.sp_Pkt.dp_Port = (port), (fp)->f_sp.sp_Pkt.dp_Type = (act), \
  51.   (fp)->f_sp.sp_Pkt.dp_Arg1 = (arg1), \
  52.   PutPacket((fp)->f_fh->fh_Type, &(fp)->f_sp))
  53.  
  54. #define SelSendPacket1(fp,port,act,arg1) \
  55.   ((fp)->f_select_sp.sp_Pkt.dp_Port = (port), (fp)->f_select_sp.sp_Pkt.dp_Type = (act), \
  56.   (fp)->f_select_sp.sp_Pkt.dp_Arg1 = (arg1), \
  57.   PutPacket((fp)->f_fh->fh_Type, &(fp)->f_select_sp))
  58.  
  59. #define SendPacket2(fp,port,act,arg1,arg2) \
  60.   ((fp)->f_sp.sp_Pkt.dp_Port = (port), (fp)->f_sp.sp_Pkt.dp_Type = (act), \
  61.   (fp)->f_sp.sp_Pkt.dp_Arg1 = (arg1), (fp)->f_sp.sp_Pkt.dp_Arg2 = (arg2), \
  62.   PutPacket((fp)->f_fh->fh_Type, &(fp)->f_sp))
  63.  
  64. #define SendPacket3(fp,port,act,arg1,arg2,arg3) \
  65.   ((fp)->f_sp.sp_Pkt.dp_Port = (port), (fp)->f_sp.sp_Pkt.dp_Type = (act), \
  66.   (fp)->f_sp.sp_Pkt.dp_Arg1 = (arg1), (fp)->f_sp.sp_Pkt.dp_Arg2 = (arg2), \
  67.   (fp)->f_sp.sp_Pkt.dp_Arg3 = (arg3), \
  68.   PutPacket((fp)->f_fh->fh_Type, &((fp)->f_sp)))
  69.  
  70. #define SendPacket4(fp,port,act,arg1,arg2,arg3,arg4) \
  71.   ((fp)->f_sp.sp_Pkt.dp_Port = (port), (fp)->f_sp.sp_Pkt.dp_Type = (act), \
  72.   (fp)->f_sp.sp_Pkt.dp_Arg1 = (arg1), (fp)->f_sp.sp_Pkt.dp_Arg2 = (arg2), \
  73.   (fp)->f_sp.sp_Pkt.dp_Arg3 = (arg3), (fp)->f_sp.sp_Pkt.dp_Arg4 = (arg4), \
  74.   PutPacket((fp)->f_fh->fh_Type, &(fp)->f_sp))
  75.  
  76. /***************************************************************************/
  77.  
  78. #define HANDLER_NIL(fp) (!(fp)->f_fh->fh_Type)
  79.  
  80. #define CTOBPTR(ptr) (((long)(ptr)) >> 2)
  81. #define BTOCPTR(ptr) ((void *)((ptr) << 2))
  82.  
  83. #endif
  84.  
  85. /* this version only works for word-aligned data as you get it from alloca()! */
  86. #define LONG_ALIGN(ptr) ((void *)((((long)(ptr))&3)?((long)ptr)+2:(long)ptr))
  87.  
  88. #endif /* _PACKETS_H */
  89.